package com.kwok.hotel.es.db.controller;


import com.kwok.hotel.es.db.common.R;
import com.kwok.hotel.es.db.entity.Hotel;
import com.kwok.hotel.es.db.entity.vo.SearchParam;
import com.kwok.hotel.es.db.service.EsSearchService;
import com.kwok.hotel.es.db.service.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.kwok.hotel.es.db.common.R.success;

/**
 * 酒店表(Hotel)表控制层
 *
 * @author makejava
 * @since 2024-06-22 17:07:13
 */
@RestController
@RequestMapping("hotel")
public class HotelController {
    /**
     * 服务对象
     */
    @Autowired
    private HotelService hotelService;

    @Autowired
    private EsSearchService esSearchService;

    /**
     * 新增数据
     *
     * @param hotel 实体对象
     * @return 新增结果
     */
    @PostMapping("save")
    public R insert(@RequestBody Hotel hotel) {
        return success(hotelService.save(hotel));
    }

    //搜索
    @PostMapping("/search")
    public R searchHotel(SearchParam searchParam){
        return R.success(esSearchService.search(searchParam));
    }

}

